﻿using BCT.Models;
using BCT.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BCT.Domains
{
    public class RoleManageDomain : IRoleManageDomain
    {
        private readonly IRoleManageRepository _roleManageRepository;

        public RoleManageDomain(RoleManageRepository roleManageRepository)
        {
            _roleManageRepository = roleManageRepository;
        }
        //获取RoleList
        public DataListModel<RoleModel> GetRoleList(ConditionModel model)
        {
            var rolelist =  _roleManageRepository.GetRoleList(model.RoleName,model.RoleDescription);
            var result = new DataListModel<RoleModel>
            {
                Count = rolelist.Count(),
                Data = rolelist.Skip((model.Page - 1) * model.Limit).Take(model.Limit).ToList()
            };
            return result;
        }
        //获取Role的下拉列表
        public List<RoleModel> GetRoleSelect()
        {
            return _roleManageRepository.GetRoleSelect();
        }
        //添加Role
        public bool AddRole(RoleModel model)
        {
            return _roleManageRepository.AddRole(model);
        }
        //修改Role
        public string ModefyRole(RoleModel model)
        {
            return _roleManageRepository.ModefyRole(model);
        }
        //禁用或启用角色
        public string LogDelete(RoleModel model)
        {
            return _roleManageRepository.LogDelete(model);
        }
    }
}
